n = int(input())
pre = list(map(int, input().split()))
post = list(map(int, input().split()))
pre.insert(0, -1)
post.insert(0, -1)


def getPos(val: int, arr: list):
    global n
    for i in range(1, 1 + n):
        if arr[i] == val: return i


G = [[-1, -1] for _ in range(135)]
flag = True


def build(l=1, r=n, L=1, R=n):
    if l < 1 or r > n or L < 1 or R > n: return
    assert pre[l] == post[R]
    idx = l
    lson, rson = 0, 0
    if l + 1 < r: lson = pre[l + 1]
    if R - 1 >= L: rson = post[R - 1]
    if lson: G[idx][0] = l + 1
    if rson: G[idx][1] = getPos(rson, pre)

    global flag
    if not lson and rson: flag = False
    if not rson and lson: flag = False
    if lson:
        l_lson = l + 1
        r_lson = getPos(rson, pre) - 1 if rson else r
        L_lson = L
        R_lson = getPos(lson, post)
        build(l_lson, r_lson, L_lson, R_lson)
    if rson:
        l_rson = getPos(rson, pre)
        r_rson = r
        L_rson = getPos(lson, post) + 1 if lson else L
        R_rson = R - 1
        build(l_rson, r_rson, L_rson, R_rson)


ans = []


def inOrder(x):
    if x == -1: return
    inOrder(G[x][0])
    ans.append(str(pre[x]))
    inOrder(G[x][1])


build()
inOrder(1)
print('Yes' if flag else 'No')
print(' '.join(ans))
